package com.cmxh.shipper.config;

import com.cmxh.shipper.service.FreightsourcesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component//被Spring容器管理
@EnableScheduling//开启定时任务
public class FreightStatusScheduler {
    @Autowired
    private FreightsourcesService freightsourcesService;

    //    @Scheduled(cron = "0/5 * * * * ?")//每五秒执行一次
    @Scheduled(cron = "0 0 * * * ?") // 每小时执行一次
//将未开始的订单状态改为进行中
    public void updateStatus() {
        freightsourcesService.updateStatus();
    }

    //
//    @Scheduled(cron = "0/5 * * * * ?")//每五秒执行一次
    @Scheduled(cron = "0 0 * * * ?") // 每小时执行一次
    //将进行中的订单状态改为已完成
    public void updateStatus2() {
        freightsourcesService.updateStatus2();
    }

    //
//    @Scheduled(cron = "0/5 * * * * ?")//每五秒执行一次
    @Scheduled(cron = "0 0 * * * ?") // 每小时执行一次
    //将已完成的订单状态改为已取消
    public void updateStatus3() {
        freightsourcesService.updateStatus3();
    }


}
